#include <future>
#include <iostream>
#include <thread>

void DoWork(std::promise<int> barrier) {
   std::this_thread::sleep_for(std::chrono::seconds(1));
   barrier.set_value(42);
}

int main() {
    std::promise<int> p1;
    std::future<int> f1 = p1.get_future();
    std::thread t1(DoWork, std::move(p1));

    std::cout << f1.get() << std::endl; // 输出 42
    t1.join();

    return 0;
}

